var i = sessionStorage.getItem("user")
if (i == null) {
    $("#dl").text("登录")
} else {
    var aa = JSON.parse(i)[0]
    $("#dl").text(aa.name)
}


//吸顶效果
window.onscroll = function () {
    //获取页面的滚动距离
    var oheight = document.documentElement.scrollTop || document.body.scrollTop;
    // console.log(oheight)
    //滚动到一定位置 div固定到顶部 js实现吸顶
    if (oheight > 110) {
        // daohang.style.position = "fixed";
        $(".xiding").css("position", "fixed")
        $(".xiding").css("top", "0")
        $(".top").css("display", "none")

    } else {
        $(".xiding").css("position", "relative")
    }

    if (oheight > 180) {
        // daohang.style.position = "fixed";
        $(".top").css("display", "none")
    }
}

$("input").blur(function (e) { 
    if($("input").val()!=""){
        $(".login").css("pointer-events","auto")
    }
    
});
$(".login").click(function () {
    $.ajax({
        type: "get",
        url: "http://127.0.0.1:3000/denglu",
        data: {
            name: $(".name").val(),
            password: $(".mima").val()
        },
        success: function (response) {
            let res = JSON.parse(response)
                    let passwords = res[0].password
                    if (passwords == $(".mima").val()) {
                        alert("登录成功")
                        sessionStorage.setItem("user",response)
                    } else {
                        alert("账号或密码有误")
                    }
        }

    });
})

